﻿@model JuCheap.Core.Models.ViewModels.BanCiViewModel

@{
    ViewData["Title"] = "Add";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}


<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>添加时间段</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form asp-controller="Banci" asp-action="Add" class="form-horizontal" method="POST">
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Name"></label>
                    <div class="col-sm-8">
                        <input asp-for="Name" class="form-control" placeholder="班次名称" />
                        <span asp-validation-for="Name"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">时间段</label>
                    <div class="col-sm-8">

                        <select name="STimePeriods" id="STimePeriods" multiple="multiple"
                                class="form-control" placeholder="开始"></select>
                        <input type="hidden" name="TimeIds" id="TimeIds" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-8">
                        <button class="btn btn-info" type="submit">保存</button>
                        <button class="btn btn-white" type="button" id="btnBack">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@section styles{
    <link href="~/js/plugins/select2/css/select2.css" rel="stylesheet" />
}

@section scripts{
        <script src="~/js/jquery.validate.js"></script>
        <script src="~/js/jquery.validate.unobtrusive.js"></script>
        <script src="~/js/base.js"></script>
    <environment names="Staging,Production">
        <script src="~/js/validate.min.js" asp-append-version="true"></script>
        <script src="~/js/base.min.js" asp-append-version="true"></script>
    </environment>
    <script src="~/js/plugins/select2/js/select2.js"></script>
    <script src="~/js/BindSelect.js"></script>
    <script>
        $("#btnBack").bind("click", function (e) {
            XPage.GoTo(e.target, "@Url.Action("Index")");
        });
        BindSelect("STimePeriods", "/TimePeriod/GetTimePeriod");
        $('#STimePeriods').change(function () {
            var o = document.getElementById('STimePeriods').getElementsByTagName('option');
            var all = "";
            for (var i = 0; i < o.length; i++) {
                if (o[i].selected) {
                    all += o[i].value + ",";
                }
            }
            all = all.substr(0, all.length - 1);
            $("#TimeIds").val(all);
        });
    </script>
}

